﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Spymaster.Entities;

namespace Spymaster.Entities.Components
{
    public class AimComponent
    {
        private GameEntity entity;

        public AimComponent(GameEntity entity)
        {
            this.entity = entity;
        }

        public void Update(Vector2 offset)
        {
            offset.Normalize();
            float dot = Vector2.Dot(offset, Vector2.UnitY);

            float angle = (float)Math.Acos(dot);

            if (offset.X <= 0)
            {
                entity.Rotation = angle;
            }
            else
            {
                entity.Rotation = -angle;
            }
        }
    }
}
